class A_QUEUE{T} < $QUEUE{T}
****
An array-based queue that expands using amortized doubling.


Ancestors
$QUEUE{_} $DISPENSER{_} $STR $CONTAINER{_}
$ELT{_} $ELT COMPARE{_}

Descendants
QUEUE{_}



Public


Features
copy: SAME
create(a: $ELT{T}): SAME
**** Create from an ordered container of elements "a" Insert all the elements in "a" into the queue such that the last element of "a" will also be the last element of the queue
create: SAME
create_capacity(allocate: INT): SAME
**** Create, allocating for "allocate" elements. Can grow later
create_from(a: ARRAY{T}): SAME
**** Create from elements of the array "a". Convenient to specify the queue using an array literal as argument
current: T
elt_eq(e1,e2:ETP):BOOL .. Included as elt_eq
**** The "less than" relation used in the sorting routines. Compares the object "id" by default. May be redefined in descendants.
elt_hash(e:ETP):INT .. Included as elt_hash
**** A hash value associated with an element. Must have the property that if "elt_eq(e1,e2)" then "elt_hash(e1)=elt_hash(e2)". Can be defined to always return 0, but many routines will then become quadratic. Uses object "id" by default. May be redefined in descendants.
elt_lt(e1,e2:ETP):BOOL .. Included as elt_lt
**** The "less than" relation used in the sorting routines. Compares the object "id" by default. May be redefined in descendants.
elt_nil: ETP .. Included as elt_nil
**** Return the nil value. If the element is under $NIL then return e.nil. Otherwise, return void
_
enq(e: T)
**** Enqueue the element "e" into the tail of the queue
has(el: T): BOOL
is_elt_nil(e:ETP):BOOL .. Included as is_elt_nil
is_empty: BOOL
remove: T
**** Error if the queue is empty
size: INT
**** Return the number of elements in the queue
str: STR
top: T
**** Return the top most elemetn of the queue

Iters
elt!: T
**** Return the elements in the queue in their normal order without changing the queue. Starts with the head of the queue and works downward


Private

attr buf: ARRAY{T};
****
attr buf: ARRAY{T};
****
build(sz: INT): SAME
attr head: INT;
**** Index of head
attr head: INT;
**** Index of head
attr tail: INT;
**** Index of next insert
attr tail: INT;
**** Index of next insert

The Sather Home Page